home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / AppleSearch / Windows / AppleSearch for Windows SDK / H / WFILES.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-25  |  12.1 KB  |  408 lines  |  [TEXT/dosa]

  1. /*====================================================================================================
  2.     File: WFILES.H
  3.  
  4.     Copyright (C) 1994-1995 Apple Computer, Inc.  All rights reserved.
  5.  
  6.     Description:
  7.  
  8.         Windows equivalent of the Macintosh include files "Files.h" and
  9.         "Aliases.h".
  10.  
  11.     Change History:
  12.  
  13.         Date        By        Description
  14.         ----        --        -----------
  15.         03/24/94    SW        ParamBlockRec - typedef added.
  16. ====================================================================================================*/
  17.  
  18. #if !defined(__FILES__) || !defined(FILES_H) || !defined(WFILES_H)
  19. #define __FILES__
  20. #define FILES_H
  21. #define WFILES_H
  22.  
  23. #if defined(WINDOWS)    // this file is only included for windows  client
  24.  
  25.  
  26. //====================================================================================================
  27. // Dependencies
  28. //====================================================================================================
  29.  
  30. #ifndef TYPES_H                    // OSErr, OSType, ScriptCode, Byte, etc.
  31.         #include "wtypes.h"
  32. #endif // TYPES_H
  33.  
  34.  
  35.  
  36.  
  37. //==============================================================================
  38. // Constants
  39. //==============================================================================
  40.  
  41. //
  42. //    dos constants
  43. //
  44. #define     MAX_NESTED_DIRECTORIES    15      //     (67 (tot path len) - 13 (file nm len)
  45.                                                     //         - 15 back slashes) / 15 (nest dir
  46.                                                     //        val = 2+ chars in    avg dir nm len
  47. #define    DOS_FILE_NM_BUFF_SZ        13    //     8 . 3 + 1 for \0
  48. #define     NT_MAX_PATH_LEN            256    //        as of Dos 6.2, only 67 chars, but
  49.                                                     //     this will be the compromise in
  50.                                                     //     anticipation of NT .. actually
  51.                                                     //        a theoretically un-limited len
  52.                                                     //        is possible with NT (oh my!)
  53.  
  54. //
  55. //    constants from files.h
  56. //
  57.  
  58. // Values passed to SetFPos() via its <offset> argument.
  59. // #define     fsAtMark         0            //    mac value is     0
  60. #define     fsFromStart       0            //          "            1
  61. #define     fsFromLEOF         2            //          "            2
  62. #define     fsFromMark         1            //          "            3
  63.  
  64. // Values passed to FSpOpenDF() via it's <permission> argument.
  65. #define    fsCurPerm        0
  66. #define    fsRdPerm            1
  67. #define    fsWrPerm            2
  68. #define    fsRdWrPerm        3
  69. #define     fsRdWrShPerm    4
  70.  
  71. //
  72. //    constants from aliases.h
  73. //
  74.  
  75. // define alias resolution action rules mask
  76.  #define kARMMountVol              0x00000001L      // mount the volume automatically
  77.  #define kARMNoUI                  0x00000002L    // no user interface allowed during resolution
  78.  #define kARMMultVols              0x00000008L     // search on multiple volumes
  79.  #define kARMSearch              0x00000100L       // search quickly
  80.  #define kARMSearchMore          0x00000200L     // search further
  81.  #define kARMSearchRelFirst     0x00000400L     // search target on a relative path first
  82.  
  83. // define alias record information types
  84.  #define asiZoneName      -3             // get zone name *
  85.  #define asiServerName  -2           // get server name
  86.  #define asiVolumeName  -1           // get volume name
  87.  #define asiAliasName      0             // get aliased file/folder/volume name
  88.  #define asiParentName  1             // get parent folder name
  89.  
  90.  
  91. //==============================================================================
  92. // Type Definitions
  93. //==============================================================================
  94.  
  95. //
  96. //    type definitions from files.h
  97. //
  98. typedef unsigned char CInfoType;
  99.  
  100.  
  101. struct FInfo {
  102.  OSType fdType;                        /*the type of the file*/
  103.  OSType fdCreator;                    /*file's creator*/
  104.  unsigned short fdFlags;            /*flags ex. hasbundle,invisible,locked, etc.*/
  105.  Point fdLocation;                    /*file's location in folder*/
  106.  short fdFldr;                            /*folder containing file*/
  107. };
  108.  
  109. typedef struct FInfo FInfo;
  110.  
  111. struct FXInfo {
  112.  short fdIconID;                    /*Icon ID*/
  113.  short fdUnused[3];                    /*unused but reserved 6 bytes*/
  114.  char fdScript;                        /*Script flag and number*/
  115.  char fdXFlags;                        /*More flag bits*/
  116.  short fdComment;                    /*Comment ID*/
  117.  long fdPutAway;                    /*Home Dir ID*/
  118. };
  119.  
  120. typedef struct FXInfo FXInfo;
  121.  
  122. struct DInfo {
  123.  Rect frRect;                        /*folder rect*/
  124.  unsigned short frFlags;            /*Flags*/
  125.  Point frLocation;                    /*folder location*/
  126.  short frView;                        /*folder view*/
  127. };
  128.  
  129. typedef struct DInfo DInfo;
  130.  
  131. struct DXInfo {
  132.  Point frScroll;                    /*scroll position*/
  133.  long frOpenChain;                    /*DirID chain of open folders*/
  134.  char frScript;                        /*Script flag and number*/
  135.  char frXFlags;                        /*More flag bits*/
  136.  short frComment;                    /*comment*/
  137.  long frPutAway;                    /*DirID*/
  138. };
  139.  
  140. typedef struct DXInfo DXInfo;
  141.  
  142.  
  143. // All FSSpec references have been changed to a c string (char*)
  144. typedef struct FSSpec
  145. {
  146.   short vRefNum;
  147.   long    parID;
  148.   char     name[64];
  149. } FSSpec, *FSSpecPtr, *FSSpecArrayPtr     ;
  150.  
  151.  
  152.  
  153. typedef void*     QElemPtr;
  154.  
  155. #define ParamBlockHeader \
  156.  QElemPtr qLink;                /*queue link in header*/ \
  157.  short qType;                    /*type byte for safety check*/ \
  158.  short ioTrap;                /*FS: the Trap*/ \
  159.  Ptr ioCmdAddr;                /*FS: address to dispatch to*/ \
  160.  ProcPtr ioCompletion;      /*completion routine addr (0 for synch calls)*/ \
  161.  OSErr ioResult;                /*result code*/ \
  162.  StringPtr ioNamePtr;          /*ptr to Vol:FileName string*/ \
  163.  short ioVRefNum;               /*volume refnum (DrvNum for Eject and MountVol)*/
  164.  
  165. struct IOParam
  166. {
  167.     ParamBlockHeader
  168.     short ioRefNum;              //refNum for I/O operation
  169.     char ioVersNum;            //version number
  170.     char ioPermssn;            //Open: permissions (byte)
  171.     Ptr ioMisc;                    //Rename: new name (GetEOF,SetEOF: logical
  172.                                     //end of file) (Open: optional ptr to buffer)
  173.                                     //(SetFileType: new type)
  174.     Ptr ioBuffer;                //data buffer Ptr
  175.     long ioReqCount;            //requested byte count; also = ioNewDirID
  176.     long ioActCount;            //actual byte count completed
  177.     short ioPosMode;            //initial file positioning
  178.     long ioPosOffset;            //file position offset
  179. };
  180.  
  181. typedef struct IOParam IOParam;
  182.  
  183. struct FileParam
  184. {
  185.     ParamBlockHeader
  186.     short ioFRefNum;                  // reference number
  187.     char ioFVersNum;                  // version number
  188.     char filler1;                //
  189.     short ioFDirIndex;              // GetFInfo directory index
  190.     unsigned char ioFlAttrib;      // GetFInfo: in-use bit=7, lock bit=0
  191.     unsigned char ioFlVersNum;      // file version number
  192.     FInfo ioFlFndrInfo;              // user info
  193.     unsigned long ioFlNum;          // GetFInfo: file number; TF- ioDirID
  194.     unsigned short ioFlStBlk;      // start file block (0 if none)
  195.     long ioFlLgLen;                  // logical length (EOF)
  196.     long ioFlPyLen;                  // physical length
  197.     unsigned short ioFlRStBlk;      // start block rsrc fork
  198.     long ioFlRLgLen;                  // file logical length rsrc fork
  199.     long ioFlRPyLen;                  // file physical length rsrc fork
  200.     unsigned long ioFlCrDat;      // file creation date& time (32 bits in secs)
  201.     unsigned long ioFlMdDat;      // last modified date and time
  202. };
  203.  
  204. typedef struct FileParam FileParam;
  205.  
  206. // 3/9/95 The precision of ioVFrBlk & ioVNmAlBlks have been changed for the
  207. //    Windows version to a long to support the volume space calculation done
  208. //    based upon DOS.  Free blocks are organized by clusters of 512 k blocks in the
  209. //    typical dos environment.  There can be so many that multiplying the
  210. //    cluster count by the cluster factor will overflow an unsigned short.
  211.  
  212. struct VolumeParam
  213. {
  214.     ParamBlockHeader
  215.     long filler2;
  216.     short ioVolIndex;                    // volume index number
  217.     unsigned long ioVCrDate;        // creation date and time
  218.     unsigned long ioVLsBkUp;        // last backup date and time
  219.     unsigned short ioVAtrb;            // volume attrib
  220.     unsigned short ioVNmFls;        // number of files in directory
  221.     unsigned short ioVDirSt;        // start block of file directory
  222.     short ioVBlLn;                        // GetVolInfo: length of dir in blocks
  223.     #if 0
  224.     unsigned short ioVNmAlBlks;        // GetVolInfo: num blks (of alloc size)
  225.     #endif
  226.     unsigned long ioVNmAlBlks;        // GetVolInfo: num blks (of alloc size)
  227.     long ioVAlBlkSiz;                    // GetVolInfo: alloc blk byte size
  228.     long ioVClpSiz;                    // GetVolInfo: bytes to allocate at a time
  229.     unsigned short ioAlBlSt;        // starting disk(512-byte) block in block map
  230.     unsigned long ioVNxtFNum;        // GetVolInfo: next free file number
  231.     #if 0
  232.     unsigned short ioVFrBlk;        // GetVolInfo: # free alloc blks for this vol
  233.     #endif
  234.     unsigned long    ioVFrBlk;        // GetVolInfo: # free alloc blks for this vol
  235. };
  236.  
  237. typedef struct VolumeParam VolumeParam;
  238.  
  239. typedef Byte    CntrlParam[50];
  240. typedef Byte    SlotDevParam[36];
  241. typedef Byte    MultiDevParam[38];
  242.  
  243. typedef union ParamBlockRec
  244. {
  245.     IOParam            ioParam;
  246.     FileParam        fileParam;
  247.     VolumeParam        volumeParam;
  248.     CntrlParam        cntrlParam;
  249.     SlotDevParam    slotDevParam;
  250.     MultiDevParam    multiDevParam;
  251. } ParamBlockRec;
  252.  
  253. typedef ParamBlockRec* ParmBlkPtr;
  254.  
  255. struct HFileInfo {
  256.  ParamBlockHeader 
  257.  short ioFRefNum;
  258.  char ioFVersNum;
  259.  char filler1;
  260.  short ioFDirIndex;
  261.  char ioFlAttrib;
  262.  char filler2;
  263.  FInfo ioFlFndrInfo;
  264.  long ioDirID;
  265.  unsigned short ioFlStBlk;
  266.  long ioFlLgLen;
  267.  long ioFlPyLen;
  268.  unsigned short ioFlRStBlk;
  269.  long ioFlRLgLen;
  270.  long ioFlRPyLen;
  271.  unsigned long ioFlCrDat;
  272.  unsigned long ioFlMdDat;
  273.  unsigned long ioFlBkDat;
  274.  FXInfo ioFlXFndrInfo;
  275.  long ioFlParID;
  276.  long ioFlClpSiz;
  277. };
  278.  
  279. typedef struct HFileInfo HFileInfo;
  280.  
  281. struct DirInfo {
  282.  ParamBlockHeader 
  283.  short ioFRefNum;
  284.  short filler1;
  285.  short ioFDirIndex;
  286.  char ioFlAttrib;
  287.  char filler2;
  288.  DInfo ioDrUsrWds;
  289.  long ioDrDirID;
  290.  unsigned short ioDrNmFls;
  291.  short filler3[9];
  292.  unsigned long ioDrCrDat;
  293.  unsigned long ioDrMdDat;
  294.  unsigned long ioDrBkDat;
  295.  DXInfo ioDrFndrInfo;
  296.  long ioDrParID;
  297. };
  298.  
  299. typedef struct DirInfo DirInfo;
  300.  
  301. union CInfoPBRec {
  302.  HFileInfo hFileInfo;
  303.  DirInfo dirInfo;
  304. };
  305.  
  306. typedef union CInfoPBRec CInfoPBRec;
  307. typedef CInfoPBRec *CInfoPBPtr;
  308.  
  309. struct FCBPBRec {
  310.  QElemPtr qLink;
  311.  short qType;
  312.  short ioTrap;
  313.  Ptr ioCmdAddr;
  314.  ProcPtr ioCompletion;
  315.  OSErr ioResult;
  316.  StringPtr ioNamePtr;
  317.  short ioVRefNum;
  318.  short ioRefNum;
  319.  short filler;
  320.  short ioFCBIndx;
  321.  short filler1;
  322.  long ioFCBFlNm;
  323.  short ioFCBFlags;
  324.  unsigned short ioFCBStBlk;
  325.  long ioFCBEOF;
  326.  long ioFCBPLen;
  327.  long ioFCBCrPs;
  328.  short ioFCBVRefNum;
  329.  long ioFCBClpSiz;
  330.  long ioFCBParID;
  331. };
  332.  
  333. typedef struct FCBPBRec FCBPBRec;
  334. typedef FCBPBRec *FCBPBPtr;
  335.  
  336. //
  337. //    type definitions from aliases.h
  338. //
  339.  
  340. // The alias structure begins with this definition followed by aliasSize
  341. // bytes of private information describing the whereabouts of a file (or
  342. //    presumably another obj)
  343. struct AliasRecord
  344. {
  345.      OSType userType;           // appl stored type like creator type
  346.      unsigned short aliasSize;  // alias record size in bytes, for appl usage
  347. };
  348.  
  349. typedef struct AliasRecord AliasRecord;
  350. typedef AliasRecord *AliasPtr, **AliasHandle;
  351.  
  352. typedef short AliasInfoType;                /* alias record information type */
  353. typedef pascal Boolean (*AliasFilterProcPtr) (CInfoPBPtr cpbPtr        /*I*/
  354.                                                             ,Boolean *quitFlag        /*O*/
  355.                                                             ,Ptr yourDataPtr);          /*I*/
  356.  
  357.  
  358.  
  359.  
  360. //====================================================================================================
  361. // Function Declarations
  362. //====================================================================================================
  363.  
  364. #if defined __cplusplus
  365. extern "C" {
  366. #endif
  367. //
  368. //    Function declarations from files.h
  369. //
  370.  
  371. OSErr pascal     FSClose(short refNum);
  372. OSErr pascal     FSRead(short refNum, long* count, void* buffer);
  373. OSErr pascal     FSWrite(short refNum, long* count, void* buffer);
  374.  
  375. OSErr pascal     GetFPos(short refNum, long* filePos);
  376. OSErr pascal     SetFPos(short refNum, short posMode, long posOffset);
  377.  
  378. OSErr pascal     GetEOF(short refNum, long* logEOF);
  379. OSErr pascal     SetEOF(short refNum, long logEOF);
  380.  
  381. OSErr pascal     PBGetFCBInfo(FCBPBPtr paramBlock,Boolean async);
  382. OSErr pascal     PBGetVInfo(ParmBlkPtr paramBlock,Boolean async);
  383.  
  384. #if 0
  385. // all FSSpec references have been changed to a char*
  386. OSErr pascal     FSMakeFSSpec(short vRefNum,long dirID,Str255 fileStr,FSSpecPtr fileFSSpec);
  387. OSErr pascal   FSpCreate(FSSpec* spec, OSType creator, OSType fileType, ScriptCode scriptTag);
  388. OSErr pascal    FSpOpenDF(FSSpec* spec, char permission, short* refNum);
  389. #endif
  390. OSErr pascal   FSpCreate(char* spec, OSType creator, OSType fileType, ScriptCode scriptTag);
  391. OSErr pascal    FSpOpenDF(char* spec, char permission, short* refNum);
  392. OSErr pascal    FSpDelete(char* spec);
  393.  
  394.  
  395. #if defined __cplusplus
  396. }
  397. #endif
  398.  
  399. #endif // WINDOWS
  400. #endif // __FILES__
  401.  
  402. //
  403. // $Log: /bogart/mac/shared/WFILES.H $
  404. // 
  405. // 15    3/09/95 5:22p Rjohnson
  406. //
  407.  
  408.